package com.sbtr.controller.system;

import com.sbtr.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.sbtr.exception.BDException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.sbtr.common.PageDto;
import com.sbtr.business.system.entity.ItemInfo;
import com.sbtr.business.system.dto.ItemInfoDto;
import com.sbtr.business.system.service.ItemInfoService;
import org.springframework.web.bind.annotation.RestController;
import com.sbtr.controller.common.CommonController;

/**
 * 项目基本信息（用于模型、特征工程、算法等模块总入口，其次用于数据汇总） 前端控制器
 *
 * @author maojianping
 * @since 2023-04-11
 */
@RestController
@RequestMapping("/itemInfo")
@Api(tags = "项目基本信息（用于模型、特征工程、算法等模块总入口，其次用于数据汇总）")
public class ItemInfoController extends CommonController<ItemInfo,ItemInfoService> {

    @GetMapping("/pageList")
    @ApiOperation(httpMethod = "GET", value = "分页列表")
    public Response<PageDto<ItemInfo>> pageList(ItemInfoDto itemInfoDto){
        return Response.success(u.pageList(itemInfoDto));
    }

    @PostMapping("/save")
    @ApiOperation(httpMethod = "POST", value = "保存")
    public Response<ItemInfo> save(@RequestBody ItemInfo itemInfo){
        itemInfo.setId(null);
        if(itemInfo.insert()){
            return Response.success(itemInfo);
        }else throw new BDException("保存失败");
    }

}

